//    Copyright (C) Kherty.  All rights reserved.
#region

using System;
using System.Xml.Serialization;
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

#endregion

namespace OpenLS.Vml.Word
{
    internal class Wrap : ShapeElement
    {
        private bool anchorlock;
        private HorizontalAnchor? anchorx;
        private VerticalAnchor? anchory;
        private WrapSide? side;
        private WrapType? type;

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.SwitchNamespace(VmlConstants.WordNamespaceUri, false).Read("wrap"))
            {
                type = c.GetOptionalEnum<WrapType>("type");
                side = c.GetOptionalEnum<WrapSide>("side");
                anchorx = c.GetOptionalEnum<HorizontalAnchor>("anchorx");
                anchory = c.GetOptionalEnum<VerticalAnchor>("anchory");
                if (c.ReaderLocalName == "anchorlock")
                {
                    using (var c2 = c.Read("anchorlock"))
                    {
                        anchorlock = true;
                    }
                }
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (var c = context.Switch(VmlConstants.WordNamespace).Write("wrap"))
            {
                c.SetOptionalEnum("type", type);
                c.SetOptionalEnum("side", side);
                c.SetOptionalEnum("anchorx", anchorx);
                c.SetOptionalEnum("anchory", anchory);
                if (anchorlock)
                {
                    using (c.Write("anchorlock"))
                    {
                    }
                }
            }
        }
    }


    internal enum VerticalAnchor
    {
        [XmlEnum("margin")] Margin,
        [XmlEnum("page")] Page,
        [XmlEnum("text")] Text,
        [XmlEnum("line")] Line,
    }

    internal enum HorizontalAnchor
    {
        [XmlEnum("margin")] Margin,
        [XmlEnum("page")] Page,
        [XmlEnum("text")] Text,
        [XmlEnum("char")] Char
    }

    internal enum WrapSide
    {
        [XmlEnum("both")] Both,
        [XmlEnum("left")] Left,
        [XmlEnum("right")] Right,

        [XmlEnum("largest")] Largest
    }

    internal enum WrapType
    {
        [XmlEnum("topAndBottom")] TopAndBottom,
        [XmlEnum("square")] Square,
        [XmlEnum("none")] None,
        [XmlEnum("tight")] Tight,
        [XmlEnum("through")] Through
    }

    internal enum BorderType
    {
        [XmlEnum("none")] None,
        [XmlEnum("single")] Single,
        [XmlEnum("thick")] Thick,
        [XmlEnum("double")] Double,
        [XmlEnum("hairline")] Hairline,
        [XmlEnum("dot")] Dot,
        [XmlEnum("dash")] Dash,
        [XmlEnum("dotDash")] DotDash,
        [XmlEnum("dashDotDot")] DashDotDot,
        [XmlEnum("triple")] Triple,
        [XmlEnum("thinThickSmall")]ThinThickSmall,
        [XmlEnum("thickThinSmall")]ThickThinSmall,
        [XmlEnum(("thickBetweenThinSmall"))]ThickBetweenThinSmall,
        [XmlEnum(("thinThick"))]ThinThick,
        [XmlEnum(("thickThin"))]ThickThin,
        [XmlEnum(("thickBetweenThin"))]ThickBetweenThin,
        [XmlEnum(("thinThickLarge"))]ThinThickLarge,
        [XmlEnum(("thickThinLarge"))]ThickThinLarge,
        [XmlEnum(("thickBetweenThinLarge"))]ThickBetweenThinLarge,
        [XmlEnum(("wave"))]Wave,
        [XmlEnum(("doubleWave"))]DoubleWave,
        [XmlEnum(("dashedSmall"))]DashedSmall,
        [XmlEnum(("dashDotStroked"))]DashDotStroked,
        [XmlEnum(("threeDEmboss"))]ThreeDEmboss,
        [XmlEnum(("threeDEngrave"))]ThreeDEngrave,
        [XmlEnum(("HTMLOutset"))]HTMLOutset,
        [XmlEnum(("HTMLInset"))]HTMLInset
    }
}